"use strict";
/**
 * @author zhaojiuyi
 * @date 2022/9/22-19:52
 * @version 1.0.0
 */
import api from "@/apis/api"
import util from "@/util/util"

const actions = {
  login: ({commit,dispatch},{token,identity}) => {
    commit("setToken",token)
    commit("setUserIdentity",identity)
    if (identity === 1){
      dispatch("setUserInfo")
    }else if (identity === 2){
      dispatch("setDocInfo")
    }else if(identity === 3){
      dispatch("setSuperAdminInfo")
    }
    // dispatch("setDocInfo")
    // dispatch("setRecordInfo")
  },
  logout: async ({commit}) => {
    const result = await api.logOut()
    if (result.code === 200) {
      commit("setUserIdentity",0)
      commit("cleanUserInfo")
      commit("clearAdminInfo")
      commit("clearToken")
      return "success"
    } else {
      util.errorMessage("服务端错误")
    }
  },

}
export default actions
